<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>大西信息科技有限公司</title>
	<link rel="icon" href="../static/img/favicon.ico" type="image/x-icon" >
    <link rel="stylesheet" href="static/css/common.css">
    <link rel="stylesheet" href="static/css/getBack.css">
	
</head>
<body>
	<div class="header">
		<div class="ie">
			<img src="static/img/logo @2x.png" alt="">
			<p>中铁十二局集团第一工程有限公司</p>
		</div>
	</div>
    <form  class="login">
        <p class="name">找回密码</p>
<!--        <p class="back">找回密码</p>-->
        <p class="phone">
            <span>+86</span>
            <span></span>
            <input type="number" placeholder="手机号" id= 'phone' autocomplete="off">
            <button type="button" class="pointer" id="send">获取验证码</button>
		</p>
		<input type="number" placeholder="短信验证码" class="message" id='code' autocomplete="off">
		<input type="password" placeholder="请输入新的密码" class="newPassword" id='pass1' autocomplete="off">
		<input type="password" placeholder="确认新的密码" class="confirm" id='pass2' autocomplete="off" onkeydown="KeyDown()" />
		<span class="err"></span>
		<button type="button" class="affirm">确 定</button><br>
		<a href="login.html" class="goback">返回登录</a>
    </form>
	<div class="footer"> 		
		<p class="dx">
		<a href="https://www.daxiit.com" target="_blank">西安大西信息科技有限公司 ©2019 </a>
		<a href="http://www.beian.miit.gov.cn" target="_blank" style="margin-left:10px;">陕ICP备15006746号</a></p>
	</div>
	
</body>
</html>
<script src="../static/js/jquery-1.8.3.js" type="text/javascript" charset="utf-8"></script>
<script src="../static/dx.js" type="text/javascript" charset="utf-8"></script>
<script src="../static/js/input.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
	$(document).ready(function(){
		// 获取验证码
		$('.pointer').click(function(){
			$('.err').hide();
			var phone = $('#phone').val();
			var isNall = DX.isNull(phone);
			if(isNall){$('.err').show();$('.err').html('手机号不能为空');return;}
			var result = DX.verPhone(phone);
			if(!result){
				$('.err').show();
				$('.err').html('');
				$('.err').html('手机号格式不正确');return;
			}
			var second = 60;
			
			
			
			// 发送验证码
			DX.ajax_method({
				'type':'POST',
				'url':'/user/login/sendSms',
				'param':{'phone':phone,'loginVerify':false},
				'callBack':function(res){
					$('.err').hide();
					if(res.code == '200'){
						var time =setInterval(function(){
							if(second == 0){
								$('#send').html("获取验证码");
								$('#send').attr('disabled',false);
								clearInterval(time);
							}else{
								$('#send').html("重新发送(" + second + ")");
								$('#send').attr('disabled',true);
								second--;
							}
							
						},1000);
						
					}else{
						$('.err').show();
						$('.err').html('');
						$('.err').html(res.msg);
					}
				}
			})
			
		})
			
		// 确认
		$('.affirm').click(function(){
			login();
		})
			
		// 点击选中
		$("#phone").focus(function(){$('.phone').addClass('active');})
		$('#phone').blur(function(){$('.phone').removeClass('active');})
		$("#code").focus(function(){$(this).addClass('active');})
		$('#code').blur(function(){$(this).removeClass('active');})
		$("#pass1").focus(function(){$(this).addClass('active');})
		$('#pass1').blur(function(){$(this).removeClass('active');})
		$("#pass2").focus(function(){$(this).addClass('active');})
		$('#pass2').blur(function(){$(this).removeClass('active');})
	})
	//enter登录
	function KeyDown(){
		if (event.keyCode == 13){
			event.returnValue=false;
			event.cancel = true;
			login();
		}
	}
	// login
	function login(){
		$('.err').hide();
		var phone = $('#phone').val();
		var pass1 = $('#pass1').val();
		var pass2 = $('#pass2').val();
		var res = DX.verPassword(pass1);
		if(!res){
			$('.err').show();
			$('.err').html('');
			$('.err').html('请输入6-11位的密码');return;
		}
		var code = $('#code').val();
		var isCode = DX.isNull(code);
		if(isCode){
			$('.err').show();
			$('.err').html('');
			$('.err').html('验证码不能为空');return;
		}
		if(pass1 == pass2){
			DX.ajax_method({
				'type':'POST',
				'url':'/user/login/findPass',
				'param':{'phone':phone,'verifyCode':code,'newPass':pass1},
				'callBack':function(res){
					if(res.code == '200'){
						window.location.href='login.html';
					}else{
						$('.err').show();
						$('.err').html('');
						$('.err').html(res.msg);
					}
				}
			})
		}else{
			$('.err').show();
			$('.err').html('密码不一致');
		}
	}
</script>